package com.pp.controller;


import com.alibaba.fastjson.JSONObject;
import com.pp.bean.GovGoodsImage;
import com.pp.service.GovGoodsImageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品详情图 前端控制器
 * </p>
 *
 * @author 张子艺
 * @since 2019-04-02
 */
@Controller
@RequestMapping("/govGoodsImage")
@Api(value = "商品多图片类controller", tags = {"商品多图片类"})
public class GovGoodsImageController {
    @Autowired
    GovGoodsImageService goodsImageService;
    /**
     * 商品轮播图上传
     *  type 类型 1 轮播图 2 详情图 宽 高中英文
     * @return
     */
    @RequestMapping(value = "/saveGoodManyImage", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "商品轮播图上传")
    public Map<String, Object> saveGoodManyImage(@RequestParam("file") MultipartFile file,  @RequestParam("jsonParam")String param ){
    return goodsImageService.saveGoodManyImage(file, JSONObject.parseObject(param,GovGoodsImage.class));
    }


    /**
     * 商品多图查询
     *  type 类型 1 轮播图 2 详情图 宽 高中英文
     * @return
     */
    @RequestMapping(value = "/findGoodManyImage", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "商品多图查询")
    public List<GovGoodsImage> findGoodManyImage(@RequestBody GovGoodsImage govGoodsImage ){
    return  goodsImageService.findGoodsImage(govGoodsImage);
    }


}
